<template>
  <div class="box">
    {{ 1 + 1 }}
  </div>
  <div>
    <button @click="t.add()">添加</button>
    <button @click="add()">添加2</button>
    <input type="text" v-model="num" />
    {{ formatNum(num) }}
  </div>
</template>
<script>
import Test from './241122/Test.class.js'
import { markRaw } from 'vue'
export default {
  data() {
    return {
      t: null,
      num: ''
    }
  },
  methods: {
    add() {
      console.log(this.t)
      this.t.add()
      Test.add()
    },
    formatNum(str) {
      let reg = /\B(?=(\d{3})+(?!\d))/g
      str = str.replace(reg, function(res) {
        return ','
      })
      return str
    }
  },
  mounted() {
    this.t = markRaw(new Test())
    let str = `12345678`
    let reg = /\B(?=(\d{3})+(?!\d))/g
    str = str.replace(reg, function(res) {
      return ','
    })
    console.log(str)
  }
}
</script>
<style type="text/css">
.box {
  width: 100px;
  height: 100px;
  border: 1px solid #000;
}
</style>
